<?php


namespace App\Models;

class Course extends Model
{
    protected $table = 'courses';

    // ============= scope ==========
    public function scopeHasPublished($query)
    {
        return $query->where('is_published', static::IS_TRUE);
    }


    // ============= relations ==========
    public function series()
    {
        return $this->belongsTo(Series::class);
    }

    public function cover()
    {
        return $this->belongsTo(Attachment::class, 'cover');
    }


    public function lessons()
    {
        return $this->hasMany(Lesson::class);
    }

    // ============= field ==========
    public function setName($name)
    {
        $this->name = $name;
    }

    public function getName()
    {
        return $this->name;
    }

    public function setDescription($description)
    {
        $this->description = $description;
    }

    public function getDescription()
    {
        return $this->description;
    }

    public function setLevel($level)
    {
        $this->level = $level;
    }

    public function getLevel()
    {
        return $this->level;
    }

    public function getCover()
    {
        return $this->cover;
    }

    public function setCover($cover)
    {
        $this->cover = $cover;
    }

    public function getPrice()
    {
        return $this->price;
    }

    public function setPrice($price)
    {
        $this->price = $price;
    }

    public function getDiscountPrice()
    {
        return $this->discount_price;
    }

    public function setDiscountPrice($discountPrice)
    {
        $this->discount_price = $discountPrice;
    }

    public function getLessonCount()
    {
        return $this->lesson_count;
    }

    public function setLessonCount($lessonCount)
    {
        $this->lesson_count = $lessonCount;
    }

    public function setPublished($isPublished)
    {
        $this->is_published = $isPublished;
    }

    public function getPublished()
    {
        return $this->is_published;
    }

    public function getSeriesId()
    {
        return $this->series_id;
    }
}